<?php
/**
 * Created by PhpStorm.
 * User: admin
 * Date: 2019/11/26
 * Time: 23:09
 */

namespace app\adminapiv3\service;

//各种路由方法
class Method
{
    /**
     * @name 需要主机在线的路由
     * @return array
     * @author wx
     * @date 2019/11/26 23:12
     */
    public function onlineHostId()
    {

        $onlineArray = array (
            'Host/hardwareUsed',
            'Netfilter/learnOff',
            'Netfilter/configModify',
            'Netfilter/initialization',
            'Netfilter/firewallConfigModify',
            'Netfilter/originRuleDelete',
            'Netfilter/createFirewallRule',
            'Netfilter/learnDataDelete',
            'Netfilter/firewallRuleAdd',
            'Netfilter/firewallRuleModify',
            'Netfilter/firewallRuleDelete',
            'Netfilter/firewallRuleOn',
            'Netfilter/firewallRuleOff',
            'Netfilter/virtualModify',
            'Netfilter/virtualDelete',
            'SystemMask/configModify',

            'HostAccessLog/open',
            'HostAccessLog/close',
            'HostAccessLog/ignore',
            'HostAccessLog/recovery',
            'NormalRuleGroup/open',
            'NormalRuleGroup/close',

            'IpsConfig/modify',
            'IpsOriginalRule/openMonitor',
            'IpsOriginalRule/closeMonitor',
            'IpsOriginalRule/del',
            'IpsOriginalRule/importRule',
        );

        return array_map('strtolower', $onlineArray);
    }


    /**
     * @name 不需要主机在线的路由
     * @return array
     * @author wx
     * @date 2019/11/27 10:25
     */
    public function offlineHostId()
    {
        $offlineArray = array(
            'Host/reinstall',//重新安装
            'Host/portList',
            'Host/detail',
            'Host/modify',
            'Host/info',
            'Netfilter/configInfo',
            'Netfilter/originRuleList',
            'Netfilter/learnDataList',
            'Netfilter/LearnDataStatisticsList',
            'Netfilter/firewallRuleList',
            'Netfilter/virtualList',
            'SystemMask/configInfo',
            'SystemMask/list',
            'HostAccessLog/list',
            'HostAccessLog/detail',
            'HostAccessLog/readConfig',
            'NormalRuleGroup/list',
            'NormalRule/list',
            'IpsRule/list',
            'NetworkAttack/list',
            'IpsConfig/findData',
            'IpsOriginalRule/list',
            'ServerDownload/create',
        );

        return array_map('strtolower', $offlineArray);
    }

    /**
     * @name 安装不需要检测的方法
     * @return array
     * @author wx
     * @date 2019/12/24 15:10
     */
    public function noInstall()
    {
        $array = array(
            'Index/isInstall'
        );

        return array_map('strtolower', $array);
    }

    /**
     * @name 不需要检测token的
     * @author wx
     * @date 2020/1/7 16:42
     */
    public function noToken()
    {
        $array = array(
            'Index/isInstall',//是否安装
            'Login/login',//登录
            'Login/code',//图形验证码
            'platform_manage.ServerAuth/platformAuthInfo',//查询授权信息
            //'HostModuleRelation/notAddedHostList',//菜单
            //'NetworkAttack/list',
            //'ServerMiddleware/list',
        );

        $array = array_map('strtolower', $array);

        return $array;
    }


    /**
     * @name 公共方法
     * @author wx
     * @date 2019/11/25 17:04
     */
    public function publicPermission()
    {
        $array = array(
            'Test/test',
            'Index/isInstall',//是否安装
            'Login/login',//登录
            'Login/code',//验证码
            'ServerAuth/platformAuthInfo',//授权信息
            'Config/get',//获取配置
            'Menu/index',//菜单
            'Host/hardwareUsed',//硬件信息
            'Host/dataStatistics',
            'Host/filterData',
            'Host/list',
            'Host/info',
            'Host/hardwareUsed',
            'Host/portList',

            'Netfilter/configInfo',
            'Netfilter/originRuleList',
            'Netfilter/learnDataList',
            'Netfilter/LearnDataStatisticsList',
            'Netfilter/firewallRuleList',
            'Netfilter/virtualList',

            'SystemMask/configInfo',
            'SystemMask/list',

            'HostAddress/list',

            'HostSoftware/list',
            'HostSoftware/detail',

            'HostService/list',
            'HostService/detail',
            'HostService/serviceHistory',

            'HostMinistry/list',

            'HostManager/list',

            'ServerAllowIp/list',

            'ServerUpdateLog/list',
            'ServerOptionHistory/list',
            'ServerOptionHistory/indexData',

            'HostAccessLog/list',
            'HostAccessLog/detail',
            'HostAccessLog/readConfig',

            'ServerAuth/list',

            'ServerDownload/list',
            'ServerDownload/del',
            'ServerDownload/download',
            'ServerDownload/create',

            'NormalRuleGroup/list',

            'NormalRule/list',

            'IpsRule/list',
            'IpsRule/indexData',

            'NetworkAttack/list',
            'NetworkAttack/indexData',
            'NetworkAttack/downloaddata',

            'IpsConfig/findData',
            'IpsOriginalRule/list',

            'index/index',
            'host/detail',
            'hostmodulerelation/notaddedhostlist',
            'netfilter/saferulelist',
            'install/online',
            'install/offline',
            'install/downloadhostfile',
            'install/userconfig',
            'install/addproxyip',
            'cmdshistory/list',
            'ServerMiddleware/list',
        );

        $array = array_map('strtolower', $array);

        return $array;
    }

    /**
     * @name 普通用户 查看权限
     * @author wx
     * @date 2019/11/25 16:59
     */
    public function userPermission()
    {
        $array = array(



        );

        $array = array_map('strtolower', $array);

        return $array;
    }

    /**
     * @name 普通管理员 操作主机
     * @author wx
     * @date 2019/11/25 16:57
     */
    public function generalPermission()
    {
        $array = array(
            'Host/add',
            'Host/delete',
            'Host/checkClient',
            'Host/reinstall',
            'Host/modify',

            'Netfilter/learnOn',
            'Netfilter/learnOff',
            'Netfilter/configModify',
            'Netfilter/initialization',
            'Netfilter/firewallConfigModify',
            'Netfilter/originRuleDelete',
            'Netfilter/createFirewallRule',
            'Netfilter/learnDataDelete',
            'Netfilter/firewallRuleAdd',
            'Netfilter/firewallRuleModify',
            'Netfilter/firewallRuleDelete',
            'Netfilter/firewallRuleOn',
            'Netfilter/firewallRuleOff',
            'Netfilter/virtualAdd',
            'Netfilter/virtualModify',
            'Netfilter/virtualDelete',

            'SystemMask/off',
            'SystemMask/on',
            'SystemMask/configModify',

            'HostAddress/add',
            'HostAddress/modify',
            'HostAddress/del',

            'HostSoftware/add',
            'HostSoftware/modify',
            'HostSoftware/del',
            'HostSoftware/retire',

            'HostService/add',
            'HostService/modify',
            'HostService/updateService',
            'HostService/endContract',
            'HostService/del',

            'HostMinistry/add',
            'HostMinistry/del',
            'HostMinistry/modify',

            'HostManager/add',
            'HostManager/del',
            'HostManager/modify',

            'HostAccessLog/open',
            'HostAccessLog/close',
            'HostAccessLog/modifyConfig',
            'HostAccessLog/ignore',
            'HostAccessLog/recovery',

            'NormalRuleGroup/open',
            'NormalRuleGroup/close',

            'NormalRule/open',
            'NormalRule/close',
            'NormalRule/setting',

            'IpsRule/open',
            'IpsRule/close',
            'IpsRule/del',
            'IpsRule/clear',
            'IpsRule/add',

            'NetworkAttack/allowIp',
            'NetworkAttack/closeAllowIp',
            'NetworkAttack/open',
            'NetworkAttack/close',

            'IpsConfig/modify',

            'IpsOriginalRule/openMonitor',
            'IpsOriginalRule/closeMonitor',
            'IpsOriginalRule/importRule',
            'ipsoriginalrule/del',

            'ServerUser/modifyUserPassword',

            'hostmodulerelation/addrelation',
            'hostmodulerelation/delrealtion',
            'netfilter/virtualon',
            'netfilter/virtualoff',

            'netfilter/saferuleon',
            'netfilter/saferuleoff',
            'serverproxy/get',
        );

        $array = array_map('strtolower', $array);

        return $array;
    }

    /**
     * @name 超级管理员 操作用户,系统设置等
     * @author wx
     * @date 2019/11/25 16:57
     */
    public function adminPermission()
    {
        $array = array(
            'Config/modify',
            'serverproxy/modify',

            'ServerAllowIp/add',
            'ServerAllowIp/modify',
            'ServerAllowIp/detail',
            'ServerAllowIp/del',

            'ServerUser/list',
            'ServerUser/add',
            'ServerUser/detail',
            'ServerUser/modify',
            'ServerUser/del',


            'ServerAuth/online',
            'ServerAuth/offline',

            'ServerUpdate/upgrade',
            'ServerUpdate/offline',

        );

        $array = array_map('strtolower', $array);

        return $array;
    }

    /**
     * @name 维护管理员权限
     * @return array
     * @author wx
     * @date 2019/12/24 14:26
     */
    public function maintainPermission()
    {
        $array = array(
            'ServerUser/list',
            'ServerUser/modifyAdmin',
        );

        $array = array_change_key_case($array);

        return $array;
    }

    /**
     * @name 所有记录日志的路由
     * @author wx
     * @date 2019/11/27 13:41
     */
    public function allLogRoute()
    {
        $array = array (
             'Test/test' => '测试',
             'Login/login' => '登录系统',
             'Host/add' => '添加资产',
             'Host/delete' => '删除资产',
             'Host/reinstall' => '重新安装资产',
             'Host/modify' => '修改资产',
             'Netfilter/learnOn' => '开始学习',
             'Netfilter/learnOff' => '停止学习',
             'Netfilter/configModify' => '修改学习配置',
             'Netfilter/initialization' => '初始化',
             'Netfilter/firewallConfigModify' => '修改防火墙配置',
             'Netfilter/originRuleDelete' => '删除默认规则',
             'Netfilter/createFirewallRule' => '生成防火墙规则',
             'Netfilter/learnDataDelete' => '删除学习数据',
             'Netfilter/firewallRuleAdd' => '添加防火墙手动规则',
             'Netfilter/firewallRuleModify' => '修改防火墙规则',
             'Netfilter/firewallRuleDelete' => '删除防火墙规则',
             'Netfilter/firewallRuleOn' => '开启防火墙规则',
             'Netfilter/firewallRuleOff' => '关闭防火墙规则',
             'Netfilter/virtualAdd' => '添加虚拟规则',
             'Netfilter/virtualModify' => '修改虚拟规则',
             'Netfilter/virtualDelete' => '删除虚拟规则',
             'SystemMask/off' => '关闭系统伪装',
             'SystemMask/on' => '开启系统伪装',
             'SystemMask/configModify' => '修改系统伪装配置',
             'HostAddress/add' => '添加资产位置',
             'HostAddress/modify' => '修改资产位置',
             'HostAddress/del' => '删除资产位置',
             'HostSoftware/add' => '添加业务系统',
             'HostSoftware/modify' => '修改业务系统',
             'HostSoftware/del' => '删除业务系统',
             'HostSoftware/retire' => '业务系统退役',
             'HostService/add' => '添加服务商',
             'HostService/modify' => '修改服务商',
             'HostService/del' => '删除服务商',
             'HostService/updateService' => '服务商续约更新',
             'HostService/endContract' => '服务商终止合同',
             'HostMinistry/add' => '添加部门',
             'HostMinistry/del' => '删除部门',
             'HostMinistry/modify' => '修改部门',
             'HostManager/add' => '添加负责人',
             'HostManager/del' => '删除负责人',
             'HostManager/modify' => '修改负责人',
             'ServerAllowIp/add' => '添加IP白名单',
             'ServerAllowIp/modify' => '修改IP白名单',
             'ServerAllowIp/del' => '删除IP白名单',
             'ServerUser/add' => '添加用户',
             'ServerUser/modify' => '修改用户',
             'ServerUser/del' => '删除用户',
             'ServerUser/modifyUserPassword' => '修改当前用户密码',
             'HostAccessLog/open' => '开启Netfilter日志记录',
             'HostAccessLog/close' => '关闭Netfilter日志记录',
             'HostAccessLog/modifyConfig' => '修改Netfilter日志配置',
             'HostAccessLog/ignore' => '忽略Netfilter日志',
             'HostAccessLog/recovery' => '恢复Netfilter日志',
             'ServerAuth/online' => '在线授权注册',
             'ServerAuth/offline' => '离线授权注册',
             'ServerDownload/del' => '删除下载',
             'ServerUpdate/upgrade' => '产品升级',
             'ServerUpdate/offline' => '产品更新',
             'NormalRuleGroup/open' => '启用官方策略组',
             'NormalRuleGroup/close' => '停用官方策略组',
             'NormalRule/open' => '启用官方规则',
             'NormalRule/close' => '停用官方规则',
             'NormalRule/setting' => '修改官方规则配置',
             'IpsRule/open' => '启用自定义规则',
             'IpsRule/close' => '停用自定义规则',
             'IpsRule/del' => '删除自定义规则',
             'IpsRule/clear' => '清空自定义规则',
             'IpsRule/add' => '添加自定义规则',
             'NetworkAttack/allowIp' => '网络日志设置白名单',
             'NetworkAttack/closeAllowIp' => '网络日志取消IP白名单',
             'NetworkAttack/downloaddata' => '网络日志下载数据包',
             'NetworkAttack/close' => '网络日志停用规则',
             'NetworkAttack/open' => '网络日志启用规则',
             'IpsConfig/modify' => '修改函谷盾功能配置',
             'IpsOriginalRule/openMonitor' => '开启监控',
             'IpsOriginalRule/closeMonitor' => '关闭监控',
             'IpsOriginalRule/del' => '删除当前规则',
             'IpsOriginalRule/importRule' => '转换客户端规则并上传',
             'ServerUser/modifyAdmin' => '修改超级管理员密码',
             'netfilter/virtualon' => '开启虚拟规则',
             'netfilter/virtualoff' => '关闭虚拟规则',
             'netfilter/saferuleon' => '开启默认规则',
             'netfilter/saferuleoff' => '关闭默认规则',
             'serverproxy/modify' => '修改出口设置',
        );

        return array_change_key_case($array);
    }

    /**
     * @name 所有不记录日志的方法
     * @return array
     * @author wx
     * @date 2019/12/24 13:39
     */
    public function allNoLogRoute()
    {
        $array = array(
            'index/isinstall',
            'index/index',
            'menu/index',
            'login/code',
            'serverauth/platformauthinfo',
            'host/list',
            'host/datastatistics',
            'host/filterdata',
            'host/checkclient',
            'host/portlist',
            'host/detail',
            'host/info',
            'host/hardwareused',
            'hostmodulerelation/notaddedhostlist',
            'netfilter/configinfo',
            'netfilter/originrulelist',
            'netfilter/learndatalist',
            'netfilter/learndatastatisticslist',
            'netfilter/firewallrulelist',
            'netfilter/virtuallist',
            'hostaccesslog/list',
            'hostaccesslog/detail',
            'hostaccesslog/readconfig',
            'netfilter/saferulelist',
            'systemmask/configinfo',
            'systemmask/list',
            'config/get',
            'hostaddress/list',
            'hostsoftware/list',
            'hostsoftware/detail',
            'hostservice/list',
            'hostservice/detail',
            'hostservice/servicehistory',
            'hostministry/list',
            'hostmanager/list',
            'serverallowip/list',
            'serverallowip/detail',
            'serveruser/list',
            'serveruser/detail',
            'serverupdatelog/list',
            'serveroptionhistory/list',
            'serveroptionhistory/indexdata',
            'serverauth/list',
            'serverdownload/list',
            'normalrulegroup/list',
            'normalrule/list',
            'ipsrule/list',
            'ipsrule/indexdata',
            'networkattack/list',
            'networkattack/indexdata',
            'ipsconfig/finddata',
            'ipsoriginalrule/list',
            'install/online',
            'install/offline',
            'install/downloadhostfile',
            'install/userconfig',
            'install/addproxyip',
            'serverproxy/get',
            'cmdshistory/list',

        );

        return array_map('strtolower', $array);
    }

    /**
     * @name 所有特殊记录日志的方法
     * @author wx
     * @date 2019/12/24 13:40
     */
    public function allSpecialLogRoute()
    {
        $array = array(
            'serverdownload/download',
            'serverdownload/create',
            'hostmodulerelation/addrelation',
            'hostmodulerelation/delrealtion',
            'config/modify',
        );

        return array_map('strtolower', $array);
    }

    /**
     * @name 平台控制器
     * @return array
     * @author wx
     * @date 2019/12/4 10:52
     */
    public function platformController()
    {
        $platformModule = array(
            'AssetManage.Host.Host',
            'AssetManage.Address.Address',
            'AssetManage.Software.Software',
            'AssetManage.ServiceProvider.Service',
            'AssetManage.Ministry.Ministry',
            'AssetManage.Ministry.Manager',
            'PlatformManage.ServerAllowIp',
            'PlatformManage.Account.ServerUser',
        );

        return array_map('strtolower', $platformModule);
    }

    /**
     * @name 关系控制器
     * @return array
     * @author wx
     * @date 2020/1/7 15:29
     */
    public function moduleRelationController()
    {
        $array = array(
            'HostModuleRelation',
        );

        return array_map('strtolower', $array);
    }

    /**
     * @name netfileter服务控制器
     * @return array
     * @author wx
     * @date 2019/12/4 11:05
     */
    public function netfilterController()
    {
        $netfilterModule = array(
            'Netfilter',    //TODO
            'HostAccessLog',
        );

        return array_map('strtolower', $netfilterModule);
    }


    public function disguiseController()
    {
        $systemMaskModule = array(
            'SystemMask',
        );

        return array_map('strtolower', $systemMaskModule);
    }

    public function wipfController()
    {
        $wipfModule = array(
            'NormalRuleGroup',
            'NormalRule',
            'IpsRule',
            'NetworkAttack',
            'IpsConfig',
            'IpsOriginalRule',
        );

        return array_map('strtolower', $wipfModule);

    }
}